microbit = codesters.Microbit()
microbit.show_string("hello")
data = microbit.get_temp()
microbit.show_number(data)
data_list = []
time_list = []
my_display = codesters.ScatterPlot(time_list, data_list)
time = 0
def interval():
data = microbit.get_temp()
data_list.append(data)
global time
time_list.append(time)
stage.event_interval(interval, 2)
t = codesters.Teacher()
updates = t.find_function("update")
try:
tval1 = updates[0][1].replace(" ", "")
tval2 = t.get_indent_at_line(updates[0][0])
except:
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success("my_display.update(time_list,data_list)" in tval1 and tval2 == 4, 'Great job')
t1.add_failure(tval1 == "DNE", "Did you drag in Update Scatter Plot?")
t1.add_failure("(time_list" not in tval1, "Did you change the first parameter of your .update() command to time_list?")
t1.add_failure("data_list)" not in tval1, "Did you change the second parameter of your .update() command to data_list?")
t1.add_failure(tval2 == 0, "Oops! Did you indent you .update() command 4 spaces inside your interval event?")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)